﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KMouse
{
    class RTC
    {
        static public DateTime GetTimeMark()
        {
            DateTime time_mark = DateTime.Now; //获取当前时间的刻度数

            return time_mark;
        }

        
        static public TimeSpan GetTimeSpan(DateTime time_mark)
        {
            return DateTime.Now.Subtract(time_mark);
        }

        public static int GetTimeSpanMS(DateTime last_time)
        {
            DateTime current_time = DateTime.Now;
            TimeSpan ts = current_time - last_time;

            int ts_ms = (ts.Hours * 3600 + ts.Minutes * 60 + ts.Seconds) * 1000 + ts.Milliseconds;

            return ts_ms;
        }

        //注意！！！下面这样的操作，是返回ms部分，而不是多少毫米，例如span是3.33ms，它就只返回33ms
        //static public int GetTimeSpanMS(TimeSpan ts1)
        //{
        //    TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks);
        //    TimeSpan ts = ts2.Subtract(ts1).Duration();

        //    return ts.Milliseconds;
        //}

        //static public int GetTimeSpanS(TimeSpan ts1)
        //{
        //    TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks);
        //    TimeSpan ts = ts2.Subtract(ts1).Duration();

        //    return ts.Seconds;
        //}
    }

#if true
    class MyTimer1 : System.Timers.Timer //集成Timer，可以传递其他参数
    {
        public delegate void tyDelegate_Callback(bool en);

        public object context;
        public Form_Main fm;
        public tyDelegate_Callback delegate_callback;
        //public Action action_callback;
    }
#endif
}
